package com.angel.web.health;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.util.JsonUtil;
import com.angel.health.BuzDoctorWork;
import com.angel.provider.health.BuzDoctorWorkProvider;
import com.github.pagehelper.StringUtil;

/**
 * @author 作者姓名 cheng
 * @version 创建时间：2016年11月18日 上午10:13:18 类说明 医生工作
 */
@Controller
@RequestMapping("doctorWork")
public class BuzDoctorWorkController {

	@Autowired
	private BuzDoctorWorkProvider bdwProvicer;

	/**
	 * 获取工作时间
	 * @param bdw
	 * @return
	 */
	@ResponseBody
	@RequestMapping("index")
	public String index(BuzDoctorWork bdw) {
		List<Map<String, Object>> bdwList = bdwProvicer.findAll(bdw);
		return JsonUtil.toJson(bdwList);
	}

	/**
	 * 分配工作时间
	 * @param bdw
	 * @return
	 */
	@ResponseBody
	@RequestMapping("workDate")
	public String workDate(BuzDoctorWork bdw) {
		if (bdw.getDoctorId() == null || StringUtil.isEmpty(bdw.getWorkDate())) {
			return "0";
		}
		int re = 0;
		if (bdw.getIsBan() == 1) {
			re = bdwProvicer.insert(bdw);
		} else {
			re = bdwProvicer.delete(bdw);
		}
		return ""+re;
	}
}
